#include "time.h"

#include <time.h>

namespace sfc::time {

using timespec_t = struct ::timespec;

auto Instant::now() -> Instant {
  auto x = timespec_t{};
  (void)::clock_gettime(CLOCK_MONOTONIC, &x);
  return {x.tv_sec * MICROS_PER_SEC + x.tv_nsec / NANOS_PER_MICRO};
}

auto System::now() -> System {
  auto x = timespec_t{};
  (void)::clock_gettime(CLOCK_REALTIME, &x);
  return {x.tv_sec * MICROS_PER_SEC + x.tv_nsec / NANOS_PER_MICRO};
}

}  // namespace sfc::time
